1. Field
Embodiments of the invention relate to the field of Z-buffering. More particularly, embodiments of the invention relate to techniques for improved Z-buffering for graphics rendering in the creation of 3-D graphics.
2. Description of Related Art
Computer graphics systems are frequently used to model a scene having three-dimensional (3-D) objects and then to display them on a two-dimensional display device such as a cathode ray tube. One such system in common use is a polygon-based, object-order graphics system in which 3-D objects in a scene are each represented by a multitude of polygons (or primitives) that approximate the shapes thereof. Depending upon the orientation selected for viewing the scene in two dimensions, many of the primitives representing objects in the scene will be hidden behind other primitives and thus not displayed. Primitives not completely hidden are termed visible and will be displayed, either in full or in part depending upon whether a portion of a given primitive is hidden, in the rendered image on the display device. As the depth complexity (i.e. the number of levels of primitives hidden behind one another) of a scene to be rendered increases, the percentage of all primitives representing the scene that will ultimately be visible by an observer on the display device decreases significantly. Thus, in many cases, most of the primitives for a scene will be hidden.
Conventional computer graphics systems typically have a frame buffer and a Z-buffer. The frame buffer is typically a memory (e.g. Dynamic Random Access Memory (DRAM) or Synchronous Random Access Memory (SRAM)) which holds the digital representation of the color and intensity for each pixel in the image. The frame buffer is also referred to as a video bitmap. The Z-buffer (also referred to as a depth buffer) is a large array of memory with an entry for each pixel in the frame buffer.
One method for determining which primitives will be visible or hidden involves the use of the Z-buffer, and is often termed Z-buffering. The Z-axis in a graphics system reflects the distance from a specific observer's viewpoint. Thus, a larger Z-value represents a greater distance from the viewpoint. Z-buffering involves the comparison of Z-values of points on generated objects to determine which object is closest to the viewpoint and therefore should appear on the two-dimensional display. As a part of processing the graphical data for a scene, pixels are generated for each of the primitives in the scene.
In conventional Z-buffer systems, as each pixel is generated, its Z coordinate (Znew) is compared with the Z coordinate previously stored in the Z-buffer (Zold). Before processing the first primitive for a scene, the Z-buffer is initialized by storing the value corresponding to a maximum distance (Zmax) in the Z-buffer entry for every pixel so that initially Zold corresponds to Zmax. In general, if Znew is less than Zold (indicating that this pixel is closer to the viewpoint than the previous viewpoint), then the pixel is written to the display device and the Z-buffer memory is updated to contain Znew. If Znew is greater than or equal to Zold, then the pixel is not written and the Z-buffer remains unchanged. All of the pixels for a primitive that is completely hidden will ultimately be overwritten in the Z-buffer during this process so that the primitive is not displayed.
In computer graphics, “rendering” is the process of translating a set of data into a picture that can be displayed. In the rendering process, a picture database typically holding polygon data is read, and calculations are performed by the rendering hardware, pixel by pixel, to decide the color of each pixel. A color calculator often performs this functionality. When a polygon is rendered, a color sample is obtained for each pixel that the polygon covers. If over-sampling is carried out, each pixel will have multiple corresponding color samples that are averaged to give the final color of the pixel. Each color sample has an associated Z-value and a location. The Z-buffer stores the smallest Z-value so far encountered for each location. If a color sample has a Z-value smaller than the value for that location as recorded in the Z-buffer, that sample is written into the frame buffer and the Z-buffer is updated. Otherwise, the color sample is discarded.
The Z-buffering process, the color determination of each pixel, as well as many other functions associated with 3-D graphics, such as utilizing different textures that may include different shadings, holes, transparent textures, translucent textures, etc., is typically performed by a rendering engine of a graphics processor. The rendering engine performs these functions utilizing a rendering pipeline. Graphics data flows along a rendering path through the rendering pipeline. Typically, Z-buffering is not performed until the very end of the rendering pipeline. Unfortunately, a major disadvantage of utilizing the conventional Z-buffering process with current rendering pipeline architectures is that it is inefficient in terms of memory usage.